#! /bin/bash

usage () {
  cat <<"EOF"

pdf2brl [options] infile outfile

Options:
  --help     Print this message
  --version  Print version information

Infile must be a pdf file. The script first calls the `pdftotext'
program, so you must have this installed on your machine. It is part
of xpdf. `pdftotext' is called with the '-raw' and '-' options, which
cause it to place its output on stdout. This is piped to `xml2brl',
which is called with the '-p' option, since output from `pdftotext' is
likely to be poorly formatted. The output file from `xml2brl' is
mostly in sensible paragraphs.
EOF
}

version () {
    cat <<EOF
$(basename $0) @VERSION@
Copyright (C) 2004-2009 ViewPlus Technologies, Inc.
Copyright (C) 2007,2009 JJB Software, Inc.
License LGPL: GNU LGPL <http://gnu.org/licenses/lgpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John J. Boyer
EOF
}

while [ $# -gt 0 ]; do
  case "$1" in
    -h | --help | -help )
      usage
      exit 0 ;;
    --version )
      version
      exit 0 ;;
    * )
      break ;;
  esac
done

pdftotext -raw $1 - |xml2brl -p >$2
